var t = null;

Page({
    data: {
        src: "",
        item: ""
    },
    onLoad: function(n) {
        // wx.createRewardedVideoAd && ((t = wx.createRewardedVideoAd({})).onError(function(t) {}), 
        // t.onClose(function(t) {
        //     t && t.isEnded;
        // }));
        var o = n.src;
        if (null != o && this.setData({
            src: o
        }), null != n.item) {
            var c = JSON.parse(n.item);
            this.setData({
                item: c
            });
        }
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    saveImg: function(n) {
        // t && t.show().catch(function() {
        //     return t.show();

        //     t.load().then(function() {
        //         return t.show();
        //     }).catch(function(t) {
        //         console.log("激励视频 广告显示失败");
        //     });
        // });
        var o = n.currentTarget.dataset.avatar;
        null != o && (o = o.replace("http", "https"));
        var c = n.currentTarget.dataset.card;
        null != c && (c = c.replace("http", "https"));
        var e = n.currentTarget.dataset.src;
        null != e && (e = e.replace("http", "https")), wx.getSetting({
            success: function(t) {
                t.authSetting["scope.writePhotosAlbum"] ? (null != o && null != c && (wx.getImageInfo({
                    src: o,
                    success: function(t) {
                        wx.saveImageToPhotosAlbum({
                            filePath: t.path,
                            success: function(t) {
                                wx.showToast({
                                    title: "下载成功",
                                    icon: "success",
                                    image: "",
                                    duration: 1e3,
                                    mask: !0,
                                    success: function(t) {},
                                    fail: function(t) {},
                                    complete: function(t) {}
                                });
                            },
                            fail: function(t) {},
                            complete: function(t) {}
                        });
                    },
                    fail: function(t) {},
                    complete: function(t) {}
                }), wx.getImageInfo({
                    src: c,
                    success: function(t) {
                        wx.saveImageToPhotosAlbum({
                            filePath: t.path,
                            success: function(t) {
                                wx.showToast({
                                    title: "下载成功",
                                    icon: "success",
                                    image: "",
                                    duration: 1e3,
                                    mask: !0,
                                    success: function(t) {},
                                    fail: function(t) {},
                                    complete: function(t) {}
                                });
                            },
                            fail: function(t) {},
                            complete: function(t) {}
                        });
                    },
                    fail: function(t) {},
                    complete: function(t) {}
                })), null != e && wx.getImageInfo({
                    src: e,
                    success: function(t) {
                        wx.saveImageToPhotosAlbum({
                            filePath: t.path,
                            success: function(t) {
                                wx.showToast({
                                    title: "下载成功",
                                    icon: "success",
                                    image: "",
                                    duration: 1e3,
                                    mask: !0,
                                    success: function(t) {},
                                    fail: function(t) {},
                                    complete: function(t) {}
                                });
                            },
                            fail: function(t) {},
                            complete: function(t) {}
                        });
                    },
                    fail: function(t) {},
                    complete: function(t) {}
                })) : wx.authorize({
                    scope: "scope.writePhotosAlbum",
                    success: function() {
                        null != o && null != c && (wx.getImageInfo({
                            src: o,
                            success: function(t) {
                                wx.saveImageToPhotosAlbum({
                                    filePath: t.path,
                                    success: function(t) {
                                        wx.showToast({
                                            title: "下载成功",
                                            icon: "success",
                                            image: "",
                                            duration: 1e3,
                                            mask: !0,
                                            success: function(t) {},
                                            fail: function(t) {},
                                            complete: function(t) {}
                                        });
                                    },
                                    fail: function(t) {},
                                    complete: function(t) {}
                                });
                            },
                            fail: function(t) {},
                            complete: function(t) {}
                        }), wx.getImageInfo({
                            src: c,
                            success: function(t) {
                                wx.saveImageToPhotosAlbum({
                                    filePath: t.path,
                                    success: function(t) {
                                        wx.showToast({
                                            title: "下载成功",
                                            icon: "success",
                                            image: "",
                                            duration: 1e3,
                                            mask: !0,
                                            success: function(t) {},
                                            fail: function(t) {},
                                            complete: function(t) {}
                                        });
                                    },
                                    fail: function(t) {},
                                    complete: function(t) {}
                                });
                            },
                            fail: function(t) {},
                            complete: function(t) {}
                        })), null != e && wx.getImageInfo({
                            src: e,
                            success: function(t) {
                                wx.saveImageToPhotosAlbum({
                                    filePath: t.path,
                                    success: function(t) {
                                        wx.showToast({
                                            title: "下载成功",
                                            icon: "success",
                                            image: "",
                                            duration: 1e3,
                                            mask: !0,
                                            success: function(t) {},
                                            fail: function(t) {},
                                            complete: function(t) {}
                                        });
                                    },
                                    fail: function(t) {},
                                    complete: function(t) {}
                                });
                            },
                            fail: function(t) {},
                            complete: function(t) {}
                        });
                    },
                    // fail: function() {
                    //     wx.showModal({
                    //         title: "未授权",
                    //         content: "请授权",
                    //         showCancel: !0,
                    //         cancelText: "取消",
                    //         cancelColor: "",
                    //         confirmText: "确定",
                    //         confirmColor: "",
                    //         success: function(t) {},
                    //         fail: function(t) {},
                    //         complete: function(t) {}
                    //     });
                    // }
                });
            }
        });
    },
    copy: function(t) {
        var n = t.currentTarget.dataset.content;
        wx.setClipboardData({
            data: n,
            success: function(t) {
                wx.showToast({
                    title: "复制完成",
                    icon: "success",
                    image: "",
                    duration: 1e3,
                    mask: !0,
                    success: function(t) {},
                    fail: function(t) {},
                    complete: function(t) {}
                });
            },
            fail: function(t) {},
            complete: function(t) {}
        });
    },
    onShareAppMessage: function() {
        return "" != this.data.src ? {
            title: "你觉得这个头像怎么样？",
            path: "/pages/photo/photo?src=" + this.data.src,
            imageUrl: this.data.src
        } : "" != this.data.item ? {
            path: "/pages/photo/photo?item=" + JSON.stringify(this.data.item)
        } : void 0;
    }
});

// var n = null;

// wx.createInterstitialAd && ((n = wx.createInterstitialAd({
//     adUnitId: ""
// })).onLoad(function() {}), n.onError(function(t) {}), n.onClose(function() {})), 
// n && n.show().catch(function(t) {
    
// });